#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
const int N = 2e5 + 5;
const ll INF = 1e18;

int n, s, t;
int a[105][105], b[105][105];
ll c[105][105];
int head[205], tot;
struct Edge {
  int v, nxt;
  int w;
  ll d;
} edges[20505];
void add(int u, int v, int w, ll d) {
  ++tot;
  edges[tot] = Edge{v, head[u], w, d};
  head[u] = tot;
}
int inq[205];
int flow[205], pre[205];
ll dis[205];
bool spfa() {
  rep(i, 1, t) dis[i] = INF, flow[i] = 1e9;
  queue<int> q;
  q.push(s);
  inq[s] = 1;
  dis[s] = 0;
  while (q.size()) {
    int u = q.front();
    q.pop();
    inq[u] = 0;
    for (int i = head[u]; i; i = edges[i].nxt) {
      int v = edges[i].v;
      int w = edges[i].w;
      ll d = edges[i].d;
      if (w && dis[v] > dis[u] + d) {
        dis[v] = dis[u] + d;
        pre[v] = i;
        flow[v] = min(flow[u], edges[i].w);
        if (!inq[v]) {
          q.push(v);
          inq[v] = 1;
        }
      }
    }
  }
  return dis[t] < INF;
}
bool check(ll x) {
  rep(i, 1, n) rep(j, 1, n) c[i][j] = -a[i][j] * 10000000LL + b[i][j] * x;
  s = n * 2 + 1, t = n * 2 + 2;
  memset(head, 0, sizeof(head));
  tot = 1;
  rep(i, 1, n) add(s, i, 1, 0), add(i, s, 0, 0);
  rep(i, 1, n) add(i + n, t, 1, 0), add(t, i + n, 0, 0);
  rep(i, 1, n) rep(j, 1, n) {
    add(i, j + n, 1, c[i][j]);
    add(j + n, i, 0, -c[i][j]);
  }
  ll sum = 0;
  while (spfa()) {  // have path from s to t
    sum += flow[t] * dis[t];
    for (int x = t; x != s;) {
      edges[pre[x]].w--;
      edges[pre[x] ^ 1].w++;
      x = edges[pre[x] ^ 1].v;
    }
  }
  return sum <= 0;
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n;
  rep(i, 1, n) rep(j, 1, n) cin >> a[i][j];
  rep(i, 1, n) rep(j, 1, n) cin >> b[i][j];

  ll l = 1, r = 1e11;
  while (l <= r) {
    ll mid = (l + r) >> 1;
    if (check(mid))
      l = mid + 1;
    else
      r = mid - 1;
  }
  cout << fixed << setprecision(6) << (r + 0.5) / 1e7;
  return 0;
}